public class Solution1806 {
    public int reinitializePermutation(int n) {
        int[] a=new int[n];
        for (int i=0;i<n;i++){
            a[i]=i;
        }
        int t=0;
        while (true){
            t++;
            int[] b=new int[n];
            for (int i=0;i<n;i++){
                b[i]=i%2==0?a[i/2]:a[n/2+(i-1)/2];
            }
            boolean f=true;
            for (int i=0;i<n;i++){
                if (b[i]!=i){
                    f=false;
                    break;
                }
            }
            if (f){
                return t;
            }
            System.arraycopy(b, 0, a, 0, n);
        }
    }

    public static void main(String[] args) {
        System.out.println(new Solution1806().reinitializePermutation(6));
    }
}
